<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

<ui:composition template="/WEB-INF/templates/template.xhtml">

	<ui:define name="title">#{resourceBundle['role.search.title']}</ui:define>

	<ui:define name="body">
		<h:form id="searchRoleForm">
			<h:panelGrid columns="5" width="60%">
				<h:outputText value="#{resourceBundle['name']}:" />
				<h:inputText value="#{roleModel.filter.name}" size="60"
					id="nameFilter" />
				<rich:message for="nameFilter" />
				<a4j:commandButton value="#{resourceBundle['search']}"
					action="search" render="roleListTable" />
				<a4j:commandButton value="#{resourceBundle['new']}" action="new" />
			</h:panelGrid>

			<br/>

			<a4j:outputPanel id="roleListTable" ajaxRendered="true">

				<rich:dataTable iterationStatusVar="status" var="role"
					value="#{roleModel.roleList}" rows="10"
					rendered="#{roleModel.roleList.rowCount >= 0}" style="width:80%;">
					<f:facet name="noData">
						<h:outputText value="#{resourceBundle['search.message.dataNotFound']}" />
					</f:facet>			
					<f:facet name="header">
						<rich:columnGroup>
							<rich:column>
								<h:outputText value="#{resourceBundle['name']}" />
							</rich:column>
							<rich:column>
								<h:outputText value="#{resourceBundle['description']}" />
							</rich:column>
							<rich:column />
						</rich:columnGroup>
					</f:facet>
					<rich:column>
						<h:outputText value="#{role.name}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{role.description}" />
					</rich:column>
					<rich:column>
						<a4j:commandLink action="edit" title="#{resourceBundle['edit']}">
							<h:graphicImage value="/resources/images/edit.gif" />
							<f:setPropertyActionListener target="#{roleModel.editedRole}"
								value="#{role}" />
						</a4j:commandLink>
						<a4j:commandLink execute="@this" render="@none"
							oncomplete="#{rich:component('confirmPane')}.show();" title="#{resourceBundle['delete']}">
							<h:graphicImage value="/resources/images/delete.gif" />
							<f:setPropertyActionListener target="#{roleModel.editedRole}"
								value="#{role}" />
						</a4j:commandLink>
					</rich:column>
					<f:facet name="footer">
						<rich:dataScroller page="#{roleModel.pageNumber}"
							renderIfSinglePage="false" />
					</f:facet>
				</rich:dataTable>
			</a4j:outputPanel>
		</h:form>

		<rich:popupPanel id="confirmPane" autosized="true">
			<h:form>
				<h:outputText value="#{resourceBundle['role.delete.confirm']}" />
				<br />
				<br />
				<a4j:commandButton value="#{resourceBundle['delete']}"
					action="delete" render="roleListTable"
					oncomplete="#{rich:component('confirmPane')}.hide();"
					execute="searchRoleForm" />
				<a4j:commandButton value="#{resourceBundle['cancel']}"
					onclick="#{rich:component('confirmPane')}.hide(); return false;" />
			</h:form>
		</rich:popupPanel>
	</ui:define>
</ui:composition>
</html>